package com.hnkywl.sts.action.djgl;

import com.hnkywl.sts.entity.sys.Gncz;
import com.hnkywl.sts.service.djgl.DjcxService;
import com.hnkywl.sts.service.sys.GnczService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.sql.Date;
import java.util.Calendar;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-6-14
 * Time: 下午4:48
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/djgl/djcx")
public class DjcxAction extends SimpleActionSupport {
    private int page;
    private int rows;
    private String dhhm;
    private Date djcxStart;
    private Date djcxEnd;
    private DjcxService djcxService;
    private java.util.Date startTime;
    private java.util.Date endTime;
    //功能操作
    private List<Gncz> gnczList;
    private GnczService gnczService;



    @Action("djcx")
    public String djcx() {
        Calendar calendar = Calendar.getInstance();
        //得到月末
        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
        endTime = calendar.getTime();
        //得到月初
        calendar.set(2011, 12, 1, 0, 0, 0);
        startTime = calendar.getTime();
        gnczList = gnczService.findGnczByJsAndUrl(request.getServletPath());
        return SUCCESS;
    }

    @Action("djcxList")
    public void djcxList() {
        String json = djcxService.djcxList(dhhm, djcxStart, djcxEnd, page, rows);
        renderJson(json);
    }


    //=======getter setter=======

    public String getDhhm() {
        return dhhm;
    }

    public void setDhhm(String dhhm) {
        this.dhhm = dhhm;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public java.util.Date getStartTime() {
        return startTime;
    }

    public void setStartTime(java.util.Date startTime) {
        this.startTime = startTime;
    }

    public java.util.Date getEndTime() {
        return endTime;
    }

    public void setEndTime(java.util.Date endTime) {
        this.endTime = endTime;
    }

    public List<Gncz> getGnczList() {
        return gnczList;
    }

    public void setGnczList(List<Gncz> gnczList) {
        this.gnczList = gnczList;
    }

    public Date getDjcxStart() {
        return djcxStart;
    }

    public void setDjcxStart(Date djcxStart) {
        this.djcxStart = djcxStart;
    }

    public Date getDjcxEnd() {
        return djcxEnd;
    }

    public void setDjcxEnd(Date djcxEnd) {
        this.djcxEnd = djcxEnd;
    }

    @Autowired
    public void setDjcxService(DjcxService djcxService) {
        this.djcxService = djcxService;
    }

    @Autowired
    public void setGnczService(GnczService gnczService) {
        this.gnczService = gnczService;
    }
}
